package cn.tannn.cat.file.server.controller.manage.dto;

import cn.tannn.jdevelops.annotations.jpa.JpaSelectIgnoreField;
import cn.tannn.jdevelops.annotations.jpa.JpaSelectOperator;
import cn.tannn.jdevelops.annotations.jpa.enums.SQLConnect;
import cn.tannn.jdevelops.annotations.jpa.enums.SQLOperatorWrapper;
import cn.tannn.jdevelops.jpa.request.PagingSorteds;
import cn.tannn.jdevelops.result.bean.SerializableBean;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 存储器分页查询
 *
 * @author tnnn
 * @version V1.0
 * @date 2024-03-09 20:51
 */
@Schema(description = "分页查询存储器配置元数据")
@ToString
@Getter
@Setter
@Valid
public class StorageConfigPage extends SerializableBean<StorageConfigPage> {

    /**
     * 字典值[Dict.value]
     */
    @Schema(description ="字典值[Dict.value]")
    @JpaSelectOperator(operatorWrapper = SQLOperatorWrapper.EQ, connect = SQLConnect.AND)
    private String storage;

    /**
     * 存储器名
     */
    @Schema(description ="存储器名")
    @JpaSelectOperator(operatorWrapper = SQLOperatorWrapper.LIKE, connect = SQLConnect.AND)
    private String name;

    /**
     * 分页排序
     */
    @Schema(description = "分页排序")
    @JpaSelectIgnoreField
    @Valid
    private PagingSorteds page;


    public PagingSorteds getPage() {
        if(page == null){
            return new PagingSorteds().fixSort(1,"master", "id");
        }else {
            return page.append(1,"master", "id");
        }
    }
}
